﻿using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Practices.ObjectBuilder;
using Microsoft.Practices.CompositeWeb;
using CMSWCSFSolution.CMS.Interface.Services;
using CMS.Model;

namespace CMSWCSFSolution.CMS.Views
{
    public class UpdateTeacherPresenter : Presenter<IUpdateTeacherView>
    {
        private ICMSService _service;
        public UpdateTeacherPresenter([CreateNew] ICMSService service)
        {
            _service = service;
        }
        public void OnSelectedAllDepartments()
        {
            View.BindDepartment = _service.GetAllDepartments();
        }
        public List<Teacher> OnSelectTeacherById()
        {
            int teacherId = View.TeacherId;
            List<Teacher> teacherList = new List<Teacher>();
            teacherList = _service.GetTeacherById(teacherId);
            return teacherList;
        }
        public List<Department> OnSelectedDepartmentById()
        {
            int teacherId = View.TeacherId;
            Teacher teacher = new Teacher(0, null, null, 0, null);
            teacher = (_service.GetTeacherById(teacherId))[0];
            Department dep = new Department();
            return _service.GetDepartmentById(teacher.DepartmentId);
        }
        public void OnUpdateTeacher()
        {
            Teacher teacher = new Teacher(0, null, null, 0, null);
            teacher = View.teacherUpdate;
            teacher.Department = (_service.GetDepartmentById(teacher.DepartmentId))[0];
            _service.UpdateTeacher(teacher);
        }
        public Department OnSelectedDepartmentById1()
        {
            int teacherId = View.TeacherId;
            Teacher teacher = new Teacher(0, null, null, 0, null);
            teacher = (_service.GetTeacherById(teacherId))[0];
            Department dep = new Department();
            return (_service.GetDepartmentById(teacher.DepartmentId))[0];
        }
        public override void OnViewLoaded()
        {
        }
        public override void OnViewInitialized()
        {
        }
    }
}




